package eco2automotive.elmFilter;
import eco2automotive.util.UtilString;
import java.util.regex.*;
 /**  
  * This class is based on regular expression
  * @version 1.0
  * @autor Fco. Javier Sánchez Esparza
  *
  */ 
public class Filter{
    String str;  
    
 /**  
  * This method find the pattern String in the str String
     * @param str 
     * @param pattern 
     * @return s, if not matches founds returns ""
  */ 
    public String getDigest(String str, String pattern){
        str=new UtilString().ClearTotalData(str); 
        Pattern pattern_var = Pattern.compile(pattern); 
        Matcher fix = pattern_var.matcher(str); 
        String s=new String();
        int count = 0;
        int start=0;
        int end=0;       
       while(fix.find()) {
           count++;
           s=str.substring( fix.start(),  fix.end());
     }
       return s;
    }                  
    
 /**  
  * Example  
     * @param args 
     */    
public static void main( String[] args ) {      
    System.out.println(new Filter().getDigest("0007770455410-32568798644444100BA0444","4100[0-9-A-Z]{4}"));
        }    
    
}
